<template>
	<view class="zuanti-container">
		<!-- 自定义导航栏 -->
		<view class="custom-nav-bar" :style="{ paddingTop: statusBarHeight + 'px' }">
			<view class="nav-content">
				<view class="nav-left">
					<text class="back-icon" @click="goBack">〈</text>
				</view>
				<view class="nav-title">
					<text class="title-text">专题</text>
				</view>
				<view class="nav-right">
					<view class="nav-actions">
						<text class="action-icon">...</text>
						<text class="action-icon">-</text>
						<text class="action-icon">○</text>
					</view>
				</view>
			</view>
		</view>

		<!-- 专题内容区域 -->
		<view class="zuanti-content">
			<!-- 专题列表 -->
			<view class="topic-list">
				<view 
					class="topic-item" 
					v-for="(topic, index) in topics" 
					:key="index"
					@click="goToShop(topic)"
				>
					<view class="topic-banner">
						<image :src="topic.image" mode="aspectFill" class="banner-img"></image>
						<view class="banner-overlay">
							<view class="banner-text">
								<text class="main-title">{{topic.mainTitle}}</text>
								<text class="sub-title">{{topic.subTitle}}</text>
								<view class="discount-tag">
									<text class="discount-text">{{topic.discountText}}</text>
								</view>
								<text class="description">{{topic.description}}</text>
							</view>
						</view>
					</view>
				</view>
			</view>
		</view>
	</view>
</template>

<script>
	export default {
		data() {
			return {
				statusBarHeight: 0, // 状态栏高度
				topics: [
					{
						id: 1,
						mainTitle: 'WINTER',
						subTitle: '冬季焕新装',
						discountText: '全场3件8折4件7折',
						description: 'The sky was as blue as a wash, and the sun was shining through',
						image: '/static/img/a.png',
						shopId: 'shop1',
						shopName: '冬季服装店'
					},
					{
						id: 2,
						mainTitle: 'WINTER',
						subTitle: '冬季焕新装',
						discountText: '全场3件8折4件7折',
						description: 'The sky was as blue as a wash, and the sun was shining through',
						image: '/static/img/a.png',
						shopId: 'shop2',
						shopName: '时尚服装店'
					}
				]
			}
		},
		onLoad() {
			// 获取状态栏高度
			this.getStatusBarHeight()
			// 获取专题数据
			this.getTopics()
		},
		methods: {
			// 获取状态栏高度
			getStatusBarHeight() {
				const systemInfo = uni.getSystemInfoSync()
				this.statusBarHeight = systemInfo.statusBarHeight
			},
			
			// 返回上一页
			goBack() {
				uni.navigateBack({
					delta: 1
				})
			},
			
			// 获取专题数据
			getTopics() {
				// TODO: 调用后端接口获取专题数据
				// uni.request({
				// 	url: 'your-api-url/topics',
				// 	method: 'GET',
				// 	success: (res) => {
				// 		this.topics = res.data
				// 	}
				// })
			},
			
			// 跳转到店铺页面
			goToShop(topic) {
				// 跳转到店铺页面，传递店铺信息
				uni.navigateTo({
					url: `/pages/dianpu/dianpu?shopId=${topic.shopId}&shopName=${encodeURIComponent(topic.shopName)}`
				})
			}
		}
	}
</script>

<style scoped>
	.zuanti-container {
		background-color: #f8f9fa;
		min-height: 100vh;
		padding-bottom: env(safe-area-inset-bottom);
	}

	/* 自定义导航栏样式 */
	.custom-nav-bar {
		position: fixed;
		top: 0;
		left: 0;
		right: 0;
		background-color: #fff;
		z-index: 999;
		border-bottom: 1rpx solid #e8e8e8;
	}

	.nav-content {
		display: flex;
		align-items: center;
		justify-content: space-between;
		padding: 20rpx 30rpx;
		height: 88rpx;
	}

	.nav-left {
		display: flex;
		align-items: center;
	}

	.back-icon {
		font-size: 36rpx;
		color: #333;
		padding: 8rpx;
		border-radius: 50%;
		transition: background-color 0.2s ease;
	}

	.back-icon:active {
		background-color: #f0f0f0;
	}

	.nav-title {
		flex: 1;
		display: flex;
		justify-content: center;
		align-items: center;
	}

	.title-text {
		font-size: 32rpx;
		font-weight: 600;
		color: #333;
	}

	.nav-right {
		display: flex;
		align-items: center;
	}

	.nav-actions {
		display: flex;
		align-items: center;
	}

	.action-icon {
		font-size: 24rpx;
		color: #666;
		margin-left: 15rpx;
	}

	/* 专题内容区域 */
	.zuanti-content {
		margin-top: 108rpx;
		padding: 20rpx;
	}

	.topic-list {
		display: flex;
		flex-direction: column;
		gap: 20rpx;
	}

	.topic-item {
		width: 100%;
		border-radius: 16rpx;
		overflow: hidden;
		box-shadow: 0 4rpx 16rpx rgba(0, 0, 0, 0.08);
		transition: all 0.2s ease;
	}

	.topic-item:active {
		transform: scale(0.98);
		box-shadow: 0 2rpx 8rpx rgba(0, 0, 0, 0.12);
	}

	.topic-banner {
		position: relative;
		width: 100%;
		height: 360rpx;
	}

	.banner-img {
		width: 100%;
		height: 100%;
		transition: transform 0.2s ease;
	}

	.topic-item:active .banner-img {
		transform: scale(1.05);
	}

	.banner-overlay {
		position: absolute;
		top: 0;
		left: 0;
		right: 0;
		bottom: 0;
		background: linear-gradient(135deg, rgba(135, 206, 235, 0.9) 0%, rgba(176, 196, 222, 0.9) 100%);
		display: flex;
		align-items: center;
		justify-content: center;
	}

	.banner-text {
		text-align: center;
		color: #fff;
		padding: 40rpx;
	}

	.main-title {
		display: block;
		font-size: 44rpx;
		font-weight: bold;
		margin-bottom: 16rpx;
		text-shadow: 0 2rpx 4rpx rgba(0, 0, 0, 0.3);
	}

	.sub-title {
		display: block;
		font-size: 28rpx;
		margin-bottom: 24rpx;
		text-shadow: 0 1rpx 2rpx rgba(0, 0, 0, 0.3);
	}

	.discount-tag {
		background-color: #ff4757;
		padding: 12rpx 24rpx;
		border-radius: 20rpx;
		margin-bottom: 16rpx;
		display: inline-block;
		box-shadow: 0 2rpx 8rpx rgba(255, 71, 87, 0.3);
	}

	.discount-text {
		color: #fff;
		font-size: 24rpx;
		font-weight: 500;
	}

	.description {
		display: block;
		font-size: 22rpx;
		color: rgba(255, 255, 255, 0.8);
		margin-top: 16rpx;
		line-height: 1.4;
	}

	/* 响应式适配 */
	@media screen and (max-width: 750rpx) {
		.zuanti-content {
			padding: 15rpx;
		}
		
		.topic-banner {
			height: 320rpx;
		}
		
		.main-title {
			font-size: 40rpx;
		}
		
		.sub-title {
			font-size: 26rpx;
		}
		
		.discount-text {
			font-size: 22rpx;
		}
		
		.description {
			font-size: 20rpx;
		}
	}

	@media screen and (max-width: 600rpx) {
		.zuanti-content {
			padding: 10rpx;
		}
		
		.topic-banner {
			height: 280rpx;
		}
		
		.main-title {
			font-size: 36rpx;
		}
		
		.sub-title {
			font-size: 24rpx;
		}
		
		.discount-text {
			font-size: 20rpx;
		}
		
		.description {
			font-size: 18rpx;
		}
		
		.banner-text {
			padding: 30rpx;
		}
	}
</style>
